package com.yjd.comm.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.alibaba.druid.support.json.JSONUtils;
import com.yjd.comm.util.CryptAES;
import com.yjd.comm.util.SecurityCode;

/**
 * @Description: 解析报文
 * @author wanganping
 * @date 2015-11-19
 * @version V1.0
 */
public class MessageParseUtils {

	/**
	 * 解析加密请求的数据为明文
	 * 
	 * @param msg
	 *            密文
	 * @param key
	 *            密钥
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public static Map<Object, Object> getMessage(String msg, String key) throws Exception {
		Map<Object, Object> MessageMap = new HashMap<Object, Object>();

		if (!StringUtils.isBlank(msg)) {
			String keyStr = SecurityCode.md5(key);
			String aesStr = CryptAES.AES_Decrypt(keyStr, msg);
			MessageMap = (Map<Object, Object>) JSONUtils.parse(aesStr);

		}

		return MessageMap;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
